using System;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Data;
using Data.DataSources;

namespace Dimok.Aspx.Manager.Lib.Controls {
	public partial class Car : Dimok.Web.UI.UserControlClientSafe {
		protected Literal ltrLoanTrackers;
		private string _vin;
		[Bindable(true)]
		public string VIN { get { return _vin; } set { _vin = value; } }

		protected override void OnPreRender(EventArgs e) {
			Page_AL pageAL = this.Page as Page_AL;
			UOX uox = pageAL == null ? new UOX() : pageAL.uox;
			if (VIN == "") VIN = Attributes["VIN"] + "";
			bb.VIN = VIN;
			ltrCarInfo.Text = uox.CarInfo.GetXml();
			ltrTrackers.Text = UOX.TrackerClass.Trackers(VIN).GetXml();

			Attributes.Add("ID", ID);
			ltrAttrs.Text = User.UserPage.BuildAttributes(Attributes);
			DataTable dtColor = SQL.ExecuteDatasetEx(uox.db, "SELECT value,style,Name FROM ColorOptions() ORDER BY RGB").Tables[0];
			ltrColors.Text = SQL.BuildSelectOptions(dtColor, "Name", "value", "style");
			ltrTrackerTypes.Text = SQL.BuildSelectOptions(new TrackerTypesDataSource().SelectEx().Table, "Name", "ID");
			ltrTrackingDeviceProviders.Text = SQL.BuildSelectOptions(new TrackingDeviceProvidersDataSource().SelectEx().Table, "Name", "ID");
			ltrCarTypes.Text = SQL.BuildSelectOptions(new CarTypesDataSource().SelectEx().Table, "Name", "ID");
			base.OnPreRender(e);
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e) {
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		///		Required method for Designer support - do not modify
		///		the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent() {
		}
		#endregion
	}
}
